//
//  FoodCell.m
//  MyProject
//
//  Created by dllo on 15/11/6.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "FoodCell.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.frame.size.width / 100
#define HEIGHT self.frame.size.height / 100

@implementation FoodCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create{
    
    self.imageWordHotFace = [[UIImageView alloc] init];
    self.labelWordHotComments = [[UILabel alloc] init];
    self.labelWordHotFine = [[UILabel alloc] init];
    self.labelWordHotFrom = [[UILabel alloc] init];
    self.labelWordHotTime = [[UILabel alloc] init];
    self.labelWordHotTitle = [[UILabel alloc] init];
    self.labelWordHotWhere = [[UILabel alloc] init];
    
    [self addSubview:self.labelWordHotWhere];
    [self addSubview:self.labelWordHotTitle];
    [self addSubview:self.labelWordHotTime];
    [self addSubview:self.labelWordHotFrom];
    
    self.labelWordHotComment = [[UILabel alloc] init];
    self.viewWordHot = [[UIView alloc] init];
    [self addSubview:self.viewWordHot];
    [self addSubview:self.labelWordHotComment];
    [self.labelWordHotComment release];
    [self.viewWordHot release];
    
    [self addSubview:self.imageWordHotFace];
    
//    self.labelWordHotComments.layer.borderWidth = 1;
//    self.labelWordHotFine.layer.borderWidth = 1;
//    self.labelWordHotFrom.layer.borderWidth = 1;
//    self.labelWordHotTime.layer.borderWidth = 1;
//    self.labelWordHotTitle.layer.borderWidth = 1;
//    self.labelWordHotWhere.layer.borderWidth = 1;
//    self.imageWordHotFace.layer.borderWidth = 1;
//    self.labelWordHotComment.layer.borderWidth = 1;
//    self.viewWordHot.layer.borderWidth = 1;
    
    
    self.buttonWordFine = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonWordHotComment = [UIButton buttonWithType:UIButtonTypeSystem];
    
    
    
    [self.viewWordHot addSubview:self.buttonWordFine];
    [self.viewWordHot addSubview:self.buttonWordHotComment];
    [self.viewWordHot addSubview: self.labelWordHotFine];
    [self.viewWordHot addSubview: self.labelWordHotComments];
    
    
    [self.imageWordHotFace release];
    [self.labelWordHotComments release];
    [self.labelWordHotFine release];
    [self.labelWordHotFrom release];
    [self.labelWordHotTime release];
    [self.labelWordHotTitle release];
    [self.labelWordHotWhere release];
    
    
}


- (void)layoutSubviews{
    
    [super layoutSubviews];
    self.imageWordHotFace.frame = CGRectMake(WIDTH * 3, HEIGHT * 15, WIDTH * 12, HEIGHT * 16);
    
    self.labelWordHotTitle.frame = CGRectMake(WIDTH * 17, HEIGHT * 20, WIDTH * 78, HEIGHT * 7);
    self.labelWordHotTime.frame = CGRectMake(WIDTH * 17, HEIGHT * 35, WIDTH * 25, HEIGHT * 5);
//    self.labelWordHotFrom.frame = CGRectMake(WIDTH * 42, HEIGHT * 27, WIDTH * 10, HEIGHT * 5);
//    self.labelWordHotWhere.frame = CGRectMake(WIDTH * 52, HEIGHT * 27, WIDTH * 15, HEIGHT * 5);
    self.labelWordHotComment.frame = CGRectMake(WIDTH * 17, HEIGHT * 47, WIDTH * 78, HEIGHT * 12);
    
//    self.viewWordHot.frame = CGRectMake(WIDTH * 17, HEIGHT * 30, WIDTH * 78, HEIGHT * 60);
    self.buttonWordHotComment.frame = CGRectMake(WIDTH * 60,  HEIGHT * 75, WIDTH * 5, HEIGHT * 10);
    self.labelWordHotComments.frame = CGRectMake(WIDTH * 65,  HEIGHT * 75, WIDTH * 10, HEIGHT * 10);
    self.buttonWordFine.frame = CGRectMake(WIDTH * 75,  HEIGHT * 75, WIDTH * 5, HEIGHT * 10);
    self.labelWordHotFine.frame = CGRectMake(WIDTH * 80,  HEIGHT * 75, WIDTH * 10, HEIGHT * 10);

    
    self.imageWordHotFace.layer.cornerRadius = HEIGHT * 16 / 2;
    self.imageWordHotFace.layer.masksToBounds = YES;
    
    
    
    
    self.labelWordHotComment.font = [UIFont systemFontOfSize:18 weight:15];
    self.labelWordHotComments.font = [UIFont systemFontOfSize:12];
    self.labelWordHotTitle.font = [UIFont systemFontOfSize:18];
    self.labelWordHotWhere.font = [UIFont systemFontOfSize:13];
    self.labelWordHotFine.font = [UIFont systemFontOfSize:12];
    self.labelWordHotTime.font = [UIFont systemFontOfSize:12];
    self.labelWordHotFrom.font = [UIFont systemFontOfSize:12];
    self.labelWordHotComments.textColor = [UIColor grayColor];
    self.labelWordHotWhere.textColor = [UIColor blueColor];
    self.labelWordHotTitle.textColor = [UIColor redColor];
    self.labelWordHotTime.textColor = [UIColor grayColor];
    self.labelWordHotFrom.textColor = [UIColor grayColor];
    self.labelWordHotFine.textColor = [UIColor grayColor];
    self.labelWordHotComments.textAlignment = 1;
    self.labelWordHotFrom.textAlignment = 1;
    self.labelWordHotFine.textAlignment = 1;
}




- (void)setModel:(modelFood *)model{
    
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [self.imageWordHotFace sd_setImageWithURL:[NSURL URLWithString: self.model.user_info[@"avatar"]]placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    self.labelWordHotTitle.text = self.model.user_info[@"user_name"];
    self.labelWordHotTime.text = self.model.time;
    self.labelWordHotComment.text = self.model.summary;
    self.labelWordHotComments.text =  [NSString stringWithFormat:@"%@", self.model.comment_num];
    self.labelWordHotFine.text = self.model.ding_num;
    
    self.buttonWordFine.titleLabel.text = @"1";
    [self.buttonWordFine setBackgroundImage:[UIImage imageNamed:@"imageWordHotFine.png"] forState:UIControlStateNormal];
    self.buttonWordHotComment.titleLabel.text = @"2";
    [self.buttonWordHotComment setBackgroundImage:[UIImage imageNamed:@"imageWordHotComment.png"] forState:UIControlStateNormal];
    
    
}












@end










